package com.dmw.service.impl;

import com.dmw.dao.DmItemDao;
import com.dmw.dao.DmItemTypeDao;
import com.dmw.entity.DmItemComment;
import com.dmw.service.ItemService;
import com.dmw.vo.FamilyPageVO.ItemInfoVO;
import com.dmw.vo.FamilyPageVO.QueryHotCityVO;
import com.dmw.vo.ImgVO.PageImgVO;
import com.dmw.vo.homePageVO.*;
import com.dmw.vo.itemInfoVO.ItemInfoOfItemIdVO;
import com.dmw.vo.itemInfoVO.ItemsOfItemIdVO;
import com.dmw.vo.itemInfoVO.ItemsPriceOfScheduleIdVO;
import com.dmw.vo.itemInfoVO.ScoreOfItemIdVO;
import com.dmw.vo.itemsListVO.SearchTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ItemServiceImpl implements ItemService {

    @Autowired
    private DmItemTypeDao typeMapper;
    @Autowired
    private DmItemDao itemMapper;

    @Override
    public List<QueryHotCityVO> queryHotCity() throws Exception {
        return itemMapper.queryHotCity();
    }

    @Override
    public List<ItemInfoVO> queryItemInfo(Map<String,Object> map) throws Exception {
        return itemMapper.queryItemInfo(map);
    }

    @Override
    public List<SearchTypeVO> queryItemType(Long parent ) throws  Exception {
        return typeMapper.queryItemType(parent);
    }

    @Override
    public List<ItemInfoOfItemIdVO> queryItemDetail(Long id) throws  Exception  {
        return itemMapper.queryItemDetail(id);
    }

    @Override
    public List<ItemsOfItemIdVO> queryItemScheduler(Long itemId) throws  Exception  {
        return itemMapper.queryItemScheduler(itemId);
    }

    @Override
    public List<ItemsPriceOfScheduleIdVO> queryItemPrice(Long scheduleId) throws Exception {
        List<ItemsPriceOfScheduleIdVO> list = itemMapper.queryItemPrice(scheduleId);
        for(int i=0;i<list.size();i++){
            Integer seatCount = itemMapper.queryItemPrice1(new Long(list.get(i).getId()));
            if(seatCount!=0) {
                list.get(i).setIsHaveSeat(1);
            }else{
                list.get(i).setIsHaveSeat(0);
            }
        }


        return list;
    }

    @Override
    public List<ScoreOfItemIdVO> queryItemComment(Long id) throws Exception {
        return itemMapper.queryItemComment(id);
    }

    @Override
    public void commitItemComment(DmItemComment comment) throws Exception {
        itemMapper.commitItemComment(comment);
    }

    @Override
    public List<PageImgVO> querySlideShowPic(Long itemTypeId) throws  Exception {
        return itemMapper.querySlideShowPic(itemTypeId);
    }

    @Override
    public List<ItemTypeVO> queryAllType() throws  Exception {
        return typeMapper.queryAllType();
    }

    @Override
    public List<TransverseNavigationVO> queryTransverse() throws  Exception {
        return typeMapper.queryTransverse();
    }

    @Override
    public List<PageImgVO> queryBanner() throws  Exception {
        return itemMapper.queryBanner();
    }

    @Override
    public List<PageImgVO> queryTodayRecommend() throws  Exception {
        return itemMapper.queryTodayRecommend();
    }

    @Override
    public List<PageImgVO> queryToSaleItem() throws  Exception {
        return itemMapper.queryToSaleItem();
    }

    @Override
    public List<FloorShowVO> queryFloorItems() throws  Exception {
        return itemMapper.queryFloorItems();
    }

    @Override
    public List<DefaultTypeVO> queryHotItems(Long itemTypeId) throws  Exception {
        return typeMapper.queryHotItems(itemTypeId);
    }

    @Override
    public List<UserInfoOfTokenVO> loadCurrentUserByToken(Long id) throws  Exception {
        return itemMapper.loadCurrentUserByToken(id);
    }

}
